import { http } from '@/utils/http/axios';
import {RequestEnum} from "@/enums/httpEnum";

/**
 * @description: 角色列表
 */
export function getRoleList(needMenus?: boolean) {
  return http.request({
    url: `/role/list`,
    method: 'GET',
    params: {
      needMenus
    }
  });
}

/**
 * 添加角色
 * @param data
 */
export function addRole(data) {
  return http.request({
    url: '/role/add',
    method: RequestEnum.POST,
    data
  }, {
    isShowSuccessMessage: true
  })
}

/**
 * 修改角色
 * @param id
 * @param data
 */
export function updateRole(id, data) {
  return http.request({
    url: `/role/update/${id}`,
    method: RequestEnum.PUT,
    data
  }, {
    isShowSuccessMessage: true
  })
}

/**
 * 删除角色
 * @param id
 */
export function deleteRole(id) {
  return http.request({
    url: `/role/delete/${id}`,
    method: RequestEnum.DELETE
  }, {
    isShowSuccessMessage: true
  })
}
